#include "portrayable.h"

Portrayable::Portrayable() : Node(){
	type_ = Node::NODE_PORTRAYABLE;
}

Portrayable::Portrayable(SDL_Texture* texture, SDL_Rect* position) : Portrayable() {
	createPortrayable(texture, position);
}

Portrayable::Portrayable(SDL_Texture* texture, int x, int y, int w, int h) : Portrayable(){
	SDL_Rect rect;
	rect.x = x;
	rect.y = y;
	rect.w = w;
	rect.h = h;
	this->createPortrayable(texture, &rect);
}

void Portrayable::setTexture(SDL_Texture* texture)
{
	texture_ = texture;
}


void Portrayable::createPortrayable(SDL_Texture* texture, SDL_Rect* position) {
	texture_ = texture;
	memcpy(&srcPosition_, position, sizeof(SDL_Rect));
	memcpy(&destPosition_, position, sizeof(SDL_Rect));
}
Portrayable::~Portrayable() {

}

void Portrayable::setDestPosition(SDL_Rect& position) {
	memcpy(&destPosition_, &position, sizeof(SDL_Rect));
}

void Portrayable::setDestPosition(int x, int y, int w, int h) {
	destPosition_.x = x;
	destPosition_.y = y;
	destPosition_.w = w;
	destPosition_.h = h;
}

void Portrayable::setDestPosition(int x, int y) {
	destPosition_.x = x;
	destPosition_.y = y;

}

void Portrayable::setSrcPosition(SDL_Rect& position) {
	memcpy(&srcPosition_, &position, sizeof(SDL_Rect));
}

void Portrayable::setSrcPosition(int x, int y, int w, int h) {
	srcPosition_.x = x;
	srcPosition_.y = y;
	srcPosition_.w = w;
	srcPosition_.h = h;
}

void Portrayable::setColor(Uint8 red, Uint8 green, Uint8 blue) {
	SDL_SetTextureColorMod(texture_, red, green, blue);
}

void Portrayable::setAlpha(Uint8 alpha) {
	SDL_SetTextureAlphaMod(texture_, alpha);
}


